package com.xiaotu.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @author 张晓
 * @create 2020-06-25 17:29
 */
public class InfoColleageIterator implements Iterator {

    //信息工程学院是以List方式存放系
    List<Department> departmentList;
    int index = -1;//索引

    public InfoColleageIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    //判断list集合中还有没有下一个元素
    @Override
    public boolean hasNext() {
        if(index >= departmentList.size()-1){
            return false;
        }else{
            index++;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentList.get(index);
    }

    //空实现remove方法
    @Override
    public void remove() {

    }
}
